package com.jhhc.StormSurgeForecast.StormSurge.ServiceImpl;

import com.jhhc.StormSurgeForecast.StormSurge.Pojo.Product.BDMS_PRODUCT_INFO;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import javax.annotation.Resource;
import java.util.List;

/**
 * (BdmsProductInfo)表服务实现类
 *
 * @author makejava
 * @since 2023-04-04 15:06:13
 */
@Service("bdmsProductInfoService")
public class BDMS_PRODUCT_INFOServiceImpl implements com.jhhc.StormSurgeForecast.StormSurge.Service.BDMS_PRODUCT_INFOService {
    @Resource
    private com.jhhc.StormSurgeForecast.StormSurge.Dao.BDMS_PRODUCT_INFOMapper BDMSPRODUCTINFOMapper;


    @Override
    public List<BDMS_PRODUCT_INFO> queryByIds(List<String> infoIds) {
        return BDMSPRODUCTINFOMapper.queryByIds(infoIds);
    }

    /**
     * 分页查询
     *
     * @param bdmsProductInfo 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @Override
    public Page<BDMS_PRODUCT_INFO> queryByPage(BDMS_PRODUCT_INFO bdmsProductInfo, PageRequest pageRequest) {
        long total = this.BDMSPRODUCTINFOMapper.count(bdmsProductInfo);
        return new PageImpl<>(this.BDMSPRODUCTINFOMapper.queryAllByLimit(bdmsProductInfo, pageRequest), pageRequest, total);
    }

    /**
     * 新增数据
     *
     * @param bdmsProductInfo 实例对象
     * @return 实例对象
     */
    @Override
    public BDMS_PRODUCT_INFO insert(BDMS_PRODUCT_INFO bdmsProductInfo) {
        this.BDMSPRODUCTINFOMapper.insert(bdmsProductInfo);
        return bdmsProductInfo;
    }

    @Override
    public BDMS_PRODUCT_INFO update(BDMS_PRODUCT_INFO bdmsProductInfo) {
        return null;
    }


    /**
     * 通过主键删除数据
     *
     * @param infoid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String infoid) {
        return this.BDMSPRODUCTINFOMapper.deleteById(infoid) > 0;
    }
}
